The following example demonstrates how to bind a grid to an array defined in the resources of the containing grid.
XAML |
Copy Code |
---|---|
<Grid xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"> <Grid.Resources> <x:Array x:Key="data_list" Type="{x:Type s:String}"> <s:String>Sunday</s:String> <s:String>Monday</s:String> <s:String>Tuesday</s:String> <s:String>Wednesday</s:String> <s:String>Thursday</s:String> <s:String>Friday</s:String> <s:String>Saturday</s:String> </x:Array> </Grid.Resources> <xcdg:DataGridControl x:Name="OrdersGrid" ItemsSource="{StaticResource data_list}"/> </Grid> |
VB.NET |
Copy Code |
---|---|
Dim data() As New String( 6 ) data( 0 ) = "Sunday" data( 1 ) = "Monday" data( 2 ) = "Tuesday" data( 3 ) = "Wednesday" data( 4 ) = "Thursday" data( 5 ) = "Friday" data( 6 ) = "Saturday" dataGridControl.ItemsSource = data |
C# |
Copy Code |
---|---|
string[] data = new string[ 7 ]; data[ 0 ] = "Sunday"; data[ 1 ] = "Monday"; data[ 2 ] = "Tuesday"; data[ 3 ] = "Wednesday"; data[ 4 ] = "Thursday"; data[ 5 ] = "Friday"; data[ 6 ] = "Saturday"; dataGridControl.ItemsSource = data; |